package com.crazy.appium.action;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.Point;

import com.crazy.appium.driver.CrazyMobileDriver;
import com.crazy.appium.page.HomePage;
import com.crazy.appium.page.LoginPage;
import com.crazy.appium.page.MinePage;
import com.crazy.appium.page.YinDaoPage;
import com.crazy.appium.utils.GetLocatorUtils;

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidElement;

/**
 * @author 沙陌  qq2879897713
 *
 */
public class LoginActions {
	public HomePage homePage;
	public MinePage minePage;
	public LoginPage loginPage;
	public YinDaoPage yindaoPage;
	public LoginActions(CrazyMobileDriver driver,String platform) {
		this.homePage=new HomePage(driver, platform);
		this.minePage=new MinePage(driver, platform);
		this.loginPage=new LoginPage(driver, platform);
		this.yindaoPage=new YinDaoPage(driver, platform);
		// TODO Auto-generated constructor stub
	}
	
	public MinePage login(String username,String pwd){
		try {
			yindaoPage.siwpeYindao();
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		
		if(yindaoPage.driver.isElementExist(yindaoPage.locator.getByLocator("start_Button"))){
			yindaoPage.ClickStart();
			homePage.driver.sleep(1000);
			homePage.clickRandom();
		}
		homePage.clickMenu("我的");
		minePage.clickLoginTv();
		loginPage.inputPhone(username);
		loginPage.inputPWD(pwd);
		loginPage.clickLoginBtn();
		try {
			loginPage.setPassword();//绘制手势锁
			homePage.clickRandom();
		} catch (Exception e) {
			// TODO: handle exception
		}

		return minePage;
	}

}
